//
//  CZStatus.swift
//  WeiBoNew
//
//  Created by 秦川 on 16/5/13.
//  Copyright © 2016年 秦川. All rights reserved.
//

import UIKit

class CZStatus: NSObject {
    //  发微博事件
    var created_at: String?
    //  微博ID
    var id: Int64 = 0
    //  微博内容
    var text: String?
    //  微博来源
    var source: String?
    //  用户模型
   var user: CZUser?
    //转发微博
    var retweeted_status: CZStatus?
    
    ///  转发数
    var reposts_count: Int = 0
    ///  评论数
    var comments_count: Int = 0
    ///  表态数
    var attitudes_count: Int = 0

    
    //  kvc构造函数
    init(dic: [String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dic)
    }
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
            guard let dic = value as? [String: AnyObject] else{
            return
            }
        user = CZUser(dic: dic)
        }else if key == "retweeted_status"{
            guard let dic = value as? [String: AnyObject] else{
                return
            }
            retweeted_status = CZStatus(dic: dic)
        
        } else{
        super.setValue(value, forKey: key)
        }
    }
//    override func setValue(value: AnyObject?, forKey key: String) {
//        if key == "user" {
//            guard let dic = value as? [String: AnyObject] else {
//                return
//            }
//            
//            user = CZUser(dic: dic)
//        } else {
//            super.setValue(value, forKey: key)
//        }
//    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }

}
